package com.example.service.impl;

import com.example.mapper.urgentTeardownStandardMapp;
import com.example.pojo.urgentTeardownStandardPojo;
import com.example.service.urgentTeardownStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * ClassName:urgentTeardownStandardImpl
 * Package:com.example.service.impl
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/10/15 15:08
 * @Version 1.0
 */
@Service
public class urgentTeardownStandardImpl implements urgentTeardownStandardService {
    @Autowired
    private urgentTeardownStandardMapp urgentTeardownStandardMapp;
    //插入一行特急分解检测标准
    public void insertOne(urgentTeardownStandardPojo pojo){
        pojo.setCreate_time(LocalDateTime.now());
        pojo.setUpdate_time(LocalDateTime.now());
        urgentTeardownStandardMapp.insertOne(pojo);
    }

    //修改一行特急分解检测标准
    public void editOneById(urgentTeardownStandardPojo pojo){
        pojo.setUpdate_time(LocalDateTime.now());
        urgentTeardownStandardMapp.editOneById(pojo);
    }

    //查询所有特急分解检测标准
    public List<urgentTeardownStandardPojo> queryAll(){
        List<urgentTeardownStandardPojo> pojoList = urgentTeardownStandardMapp.queryAll();
        return pojoList;
    }

    //查询一个字段为某值的数据
    public List<urgentTeardownStandardPojo> queryOneField(Map<String, Object> map){
        String fieldName = String.valueOf(map.get("fieldName"));
        String fieldValue = String.valueOf(map.get("fieldValue"));
        List<urgentTeardownStandardPojo> pojo=urgentTeardownStandardMapp.queryOneField(fieldName,fieldValue);
        return pojo;
    }

    //根据分页查询特急分解检测标准
    public List<urgentTeardownStandardPojo> queryByPage(Map<String, Object> map){
        Integer page =(Integer) map.get("page");
        Integer size=(Integer) map.get("size");
        Integer startRow=page*size;
        List<urgentTeardownStandardPojo> urgentTeardownStandardPojos=urgentTeardownStandardMapp.queryByPage(startRow, size);
        return urgentTeardownStandardPojos;
    }
    //查询所有特急分解检测标准总条数
    public Integer queryQuantity(){
        Integer quantity= urgentTeardownStandardMapp.queryQuantity();
        return quantity;
    }
}
